var io = require('socket.io').listen(80)

var all_sockets = null;
var get_id = [];

io.sockets.on('connection', function (socket) {
	var location = {
		data:[],
		push:function(data){
			this.data.push(data);
			this.pop();
		},
		pop:function(){
            all_sockets = socket.manager.sockets.sockets;
            var data = this.data.pop();
            get_id.forEach(function(id){
	            s = all_sockets[id];
	            console.log(id);
	           	s && s.emit('get',data);
            });
		}
	};
	socket.on('get',function(data){
        console.log(socket.id);
		console.log('get:--->',data);
        get_id.push(socket.id);
	});
	socket.on('location',function(data){
        console.log(socket.id);
		console.log('location:--->',data);
        location.push(data);
	})
});